import java.util.ArrayList;
import java.util.List;

public class MyTank extends Tank {
    List<Shot> shots= new ArrayList<>();
    static final int MAX_SHOTS = 5;
    public MyTank(int x, int y) {
        super(x, y);
    }
    //射击
    public void shotEnemy(){
        if (shots.size() == MAX_SHOTS) {
            return;
        }
        Shot shot = null;
        switch (getDirect()) {
            case 0:
                shot = new Shot(getX() + 20, getY(), 0);
                shots.add(shot);
                break;
            case 1:
                shot = new Shot(getX() + 60, getY() + 20, 1);
                shots.add(shot);
                break;
            case 2:
                shot = new Shot(getX() + 20, getY() + 60, 2);
                shots.add(shot);
                break;
            case 3:
                shot = new Shot(getX(), getY() + 20, 3);
                shots.add(shot);
                break;
        }
        new Thread(shot).start();
    }
}
